local gamelib = require "club.threecard.gamelib"
local game = require "club.threecard.bjracing"

local rank_item = gamelib.ui.element()

function rank_item:ctor()
    local containerConfig = game.require "game.PokerContainerConfig_gamescene"
    self.poker_container = gamelib.GameCore.Poker.PokerContainer.new(containerConfig);
end

function rank_item:on_injected(bind)
    self.poker_container:set_gameobject(self.poker_container_obj, true);
end

function rank_item:on_scroll_cell_update(data, index)
    self.name_txt.text = string.format("#%s", data.user_id);
    self.bet_txt.text = string.format( "下注:%s  赢得:%s", data.bets, data.wins);
    self.score_txt.text = string.format("$%s", data.hand_rank_score);
    local t = 
    {
        [1] = "st";
        [2] = "nd";
        [3] = "rd";
    }
    self.rank_txt.text = data.rank .. (t[data.rank] or "th");
    self.poker_container:Mopai(data.hand_card_uids);
end

return rank_item